/**
 * @file sfifo.h
 * @author xy
 * @brief 
 * @version 0.1
 * @date 2024-12-28
 * 
 * @copyright Copyright (c) 2024
 * 
 */

#ifndef SFIFO_H
#define SFIFO_H

#ifdef __cplusplus
extern "C" {
#endif

struct sfifo_s
{
    unsigned int in;
    unsigned int out;
    unsigned int mask;
    unsigned int esize;
    void *data;
};


int sfifo_init(struct sfifo_s *fifo, void *buf, unsigned int size,
               unsigned int esize);

unsigned int sfifo_in(struct sfifo_s *fifo, const void *buf, unsigned int len);

unsigned int sfifo_out(struct sfifo_s *fifo, void *buf, unsigned int len);

void sfifo_clear_in(struct sfifo_s *fifo);

void sfifo_clear_out(struct sfifo_s *fifo);

unsigned int sfifo_used(struct sfifo_s *fifo);

unsigned int sfifo_free(struct sfifo_s *fifo);

#ifdef __cplusplus
}
#endif


#endif //SFIFO_H
